package br.ucb.sispro.util;

import br.ucb.sispro.control.Control;
import br.ucb.sispro.managedBean.MB;
import br.ucb.sispro.model.Entity;
import br.ucb.sispro.model.Estabelecimento;


public class StatusThread extends MB<Estabelecimento> implements Runnable {

	public void run() {
		while(true){
			try {
				Thread.sleep(5000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			initializeEntity();
			System.out.println("19 " +  getControl().findByHQLLivre(getEntity(),"ativo","N").size());
			Atualiza.setCont(getControl().findByHQLLivre(getEntity(),"ativo","N").size());
			if(Atualiza.getCont()!=0){
				Atualiza.setNum(0);
			}else{
				Atualiza.setNum(1);
			}
			System.out.println("22Atualiza.getCont();"+Atualiza.getCont());

		}
	}
	@Override
	protected void initializeEntity() {
		setEntity(new Estabelecimento());
	}
}